From fe1907708c4edb5a97184a2e027b7a028a7b5554 Mon Sep 17 00:00:00 2001 From: Dieter Verfaillie Date: Wed, 25 Jan 2012 13:02:21 +0100 Subject: [PATCH] win32: fix gdk_win32_window_raise When calling gtk_window_present(), gdk_win32_window_raise did not actually raise the window anymore. Replacing BringWindowToTop() with SetForegroundWindow() fixes this. During testing, we also discovered that sometimes SetForeGroundWindow() will (correctly) refuse to raise the window and fail(for example: sometimes when dragging a different application at the time of a gtk_window_present() call). To prevent a GdkWarning from being produced, usage of the API_CALL macro has been removed for this case. Additional goodies of SetForeGroundWindow: - it brings the window to the front when the process owning the window to raise is the foreground process (for example when gtk_window_present is called from a GtkStatusIcon's activate signal handler) - it limits itself to flashing the task bar button associated with the window if the process owning the window to raise is *not* the foreground process (for example when gtk_window_present is called from a g_timeout_add callback function) https://bugzilla.gnome.org/show_bug.cgi?id=665760 --- gdk/win32/gdkwindow-win32.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gdk/win32/gdkwindow-win32.c b/gdk/win32/gdkwindow-win32.c index 45457a346d..c6100f5155 100644 --- a/gdk/win32/gdkwindow-win32.c +++ b/gdk/win32/gdkwindow-win32.c @@ -1503,7 +1503,11 @@ gdk_win32_window_raise (GdkWindow *window) 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE)); else if (window->accept_focus) - API_CALL (BringWindowToTop, (GDK_WINDOW_HWND (window))); + /* Do not wrap this in an API_CALL macro as SetForegroundWindow might + * fail when for example dragging a window belonging to a different + * application at the time of a gtk_window_present() call due to focus + * stealing prevention. */ + SetForegroundWindow (GDK_WINDOW_HWND (window)); else API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window), HWND_TOP, 0, 0, 0, 0, -- 2.30.2